home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Periodicals / develop / develop Issue 6 / develop 6 code / TCP / NewsWatcher / NewsWatcher 2.0d15 source / source / about.c next >
Encoding:
C/C++ Source or Header  |  1993-08-18  |  3.2 KB  |  110 lines  |  [TEXT/KAHL]

  1. /*----------------------------------------------------------------------------
  2.  
  3.     about.c
  4.  
  5.     This module presents the about box.
  6.     
  7.     Portions copyright © 1990, Apple Computer.
  8.     Portions copyright © 1993, Northwestern University.
  9.  
  10. ----------------------------------------------------------------------------*/
  11.  
  12. #include <string.h>
  13.  
  14. #include "glob.h"
  15. #include "about.h"
  16. #include "dlgutil.h"
  17. #include "util.h"
  18.  
  19.  
  20.  
  21. #define    kAboutID            128        /* About box dialog */
  22. #define kAboutText             128        /* resource id of about box text 'TEXT' resource */
  23.  
  24. #define kBigIconPictItem    2        /* item number of big icon pict */
  25. #define kLogoPictItem        3        /* item number of logo pict */
  26. #define kAboutBoxUserItem     5        /* item number of user item for text */
  27.  
  28. #define kBigIconPictColor    128        /* resource id of big icon color picture */
  29. #define kBigIconPictBW        129        /* resource id of big icon B&W picture */
  30. #define kLogoPictColor        130     /* resource id of logo color picture */
  31. #define kLogoPictBW            131     /* resource id of logo B&W picture */
  32.  
  33.  
  34.  
  35. static Boolean gMagicCookieShowSampleNewsServerErrorMessage;
  36.  
  37.  
  38.  
  39.  
  40. /*----------------------------------------------------------------------------
  41.     AboutBoxFilter 
  42.     
  43.     About box dialog filter.
  44. ----------------------------------------------------------------------------*/
  45.  
  46. static pascal Boolean AboutBoxFilter (DialogPtr dlg, EventRecord *theEvent, short *itemHit)
  47. {
  48.     if (theEvent->what == keyDown && 
  49.         (theEvent->message & charCodeMask) == '1' &&
  50.         (theEvent->modifiers & cmdKey) != 0) 
  51.     {
  52.         gMagicCookieShowSampleNewsServerErrorMessage = true;
  53.         *itemHit = ok;
  54.         return true;
  55.     }
  56.     return DialogFilter(dlg, theEvent, itemHit);
  57. }
  58.  
  59.  
  60.  
  61. /*----------------------------------------------------------------------------
  62.     DoAboutBox
  63.     
  64.     Present the about box.
  65. ----------------------------------------------------------------------------*/
  66.  
  67. void DoAboutBox (void)
  68. {
  69.     DialogPtr dlg;
  70.     short item;
  71.     PicHandle bigIconPict, logoPict;
  72.     Handle vers1Resource;
  73.     short bigIconPictID, logoPictID;
  74.     CStr255 sampleNewsServerErrorMessage;
  75.     Handle text;
  76.     short fontNum;
  77.     
  78.     dlg = MyGetNewDialog(kAboutID);
  79.     if (GetPixelDepth(&dlg->portRect) <= 2) {
  80.         bigIconPictID = kBigIconPictBW;
  81.         logoPictID = kLogoPictBW;
  82.     } else {
  83.         bigIconPictID = kBigIconPictColor;
  84.         logoPictID = kLogoPictColor;
  85.     }
  86.     bigIconPict = GetPicture(bigIconPictID);
  87.     HNoPurge((Handle)bigIconPict);
  88.     logoPict = GetPicture(logoPictID);
  89.     HNoPurge((Handle)logoPict);
  90.     DlgSetPict(dlg, kBigIconPictItem, bigIconPict);
  91.     DlgSetPict(dlg, kLogoPictItem, logoPict);
  92.     vers1Resource = GetResource('vers', 1);
  93.     HLock(vers1Resource);
  94.     ParamText((StringPtr)*vers1Resource+6, "\p", "\p", "\p");
  95.     HUnlock(vers1Resource);
  96.     gMagicCookieShowSampleNewsServerErrorMessage = false;
  97.     GetFNum("\pGeneva", &fontNum);
  98.     text = GetResource('TEXT', kAboutText);
  99.     SetItemReadOnly(dlg, kAboutBoxUserItem, text, fontNum, 9);
  100.     MyModalDialog(AboutBoxFilter, &item, false, true);
  101.     MyDisposDialog(dlg);
  102.     HPurge((Handle)bigIconPict);
  103.     HPurge((Handle)logoPict);
  104.     if (gMagicCookieShowSampleNewsServerErrorMessage) {
  105.         strcpy(sampleNewsServerErrorMessage, "999 This is a sample news server error message.");
  106.         strcat(sampleNewsServerErrorMessage, CRLF);
  107.         NewsServerErrorMessage("SAMPLE", sampleNewsServerErrorMessage);
  108.     }
  109. }
  110.